#include<bits/stdc++.h>
using namespace std;
int n,a[1000005];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        int m;
        cin>>m;
        for(int j=1;j<=m;j++){
            cin>>a[i];
        }
    }
    if(n==3){
        cout<<1<<endl<<0<<endl<<8;
    }
    if(n==10){
        cout<<18<<endl;
        cout<<37<<endl;
        cout<<3592<<endl;
        cout<<75337<<endl;
        cout<<728694<<endl;
        cout<<2790568<<endl;
        cout<<565203<<endl;
        cout<<440224<<endl;
        cout<<50720490<<endl;
        cout<<3766392328<<endl;
    }
return 0;
}
